using System;

using MiP.Common;

namespace MiP.XmlCmd.Shell.Logging
{
    public class ConsoleLogger : ILogger
    {
        public ConsoleLogger()
        {
            LogLevel = LogLevel.Info;
        }

        public void Debug(string message, params object[] messageArgs)
        {
            Log(LogLevel.Debug, message, messageArgs);
        }

        public void Info(string message, params object[] messageArgs)
        {
            Log(LogLevel.Info, message, messageArgs);
        }

        public void Warn(string message, params object[] messageArgs)
        {
            Log(LogLevel.Warn, message, messageArgs);
        }

        public void Error(string message, params object[] messageArgs)
        {
            Log(LogLevel.Error, message, messageArgs);
        }

        private void Log(LogLevel level, string message, params object[] messageArgs)
        {
            if (level >= LogLevel)
            {
                if (messageArgs != null && messageArgs.Length>0)
                    Console.WriteLine(message, messageArgs);
                else
                    Console.WriteLine(message);
            }
        }

        public LogLevel LogLevel
        {
            get;
            set;
        }
    }
}